home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.9 KB | 248 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: SLResSin.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWRESACC_H
- #include "FWResAcc.h"
- #endif
-
- #ifndef FWEXCEPT_H
- #include "FWExcept.h"
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwresour
- #endif
-
- #include "SLMemSin.xh"
-
- /*
- * This file was generated by the SOM Compiler.
- * Generated using:
- * SOM Emitter emitxtm.dll: 2.33
- */
-
- #define FW_OResourceSink_Class_Source
- #include "SLResSin.xih"
-
-
- //========================================================================================
- // class FW_CPrivResSinRep
- //========================================================================================
-
- class FW_CPrivResSinRep
- {
- public:
- FW_DECLARE_AUTO(FW_CPrivResSinRep)
-
- FW_CAcquireResourceData fResource;
- FW_OMemorySink* fMemorySink;
-
- FW_CPrivResSinRep(Environment* ev, FW_OResource* theResource);
- ~FW_CPrivResSinRep();
- };
-
-
- FW_DEFINE_AUTO(FW_CPrivResSinRep)
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivResSinRep::FW_CPrivResSinRep
- //----------------------------------------------------------------------------------------
-
- inline FW_CPrivResSinRep::FW_CPrivResSinRep(Environment* ev, FW_OResource* theResource) :
- fResource(ev, theResource)
- {
- long resourceSize = fResource.GetSize();
-
- fMemorySink = new FW_OMemorySink;
- fMemorySink->InitFromBuffer(ev, fResource.GetData(), resourceSize, resourceSize);
-
- FW_END_CONSTRUCTOR
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivResSinRep::~FW_CPrivResSinRep
- //----------------------------------------------------------------------------------------
-
- inline FW_CPrivResSinRep::~FW_CPrivResSinRep()
- {
- FW_START_DESTRUCTOR
- delete fMemorySink;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_OResourceSink__InitFromOResource
- //----------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK FW_OResourceSink__InitFromOResource(FW_OResourceSink *somSelf, Environment *ev,
- FW_OResource* theResource)
- {
- FW_OResourceSinkData *somThis = FW_OResourceSinkGetData(somSelf);
-
- FW_SOM_TRY
- {
- somThis->fRep = FW_NEW(FW_CPrivResSinRep, (ev, theResource));
- }
- FW_SOM_CATCH
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_OResourceSink__somInit
- //----------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK FW_OResourceSink__somInit(FW_OResourceSink *somSelf)
- {
- FW_OResourceSinkData *somThis = FW_OResourceSinkGetData(somSelf);
-
- FW_OResourceSink_parent_FW_ORandomAccessSink_somInit(somSelf);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_OResourceSink__somUninit
- //----------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK FW_OResourceSink__somUninit(FW_OResourceSink *somSelf)
- {
- FW_OResourceSinkData *somThis = FW_OResourceSinkGetData(somSelf);
-
- FW_SOM_UNINIT_TRY
- {
- delete somThis->fRep;
- FW_OResourceSink_parent_FW_ORandomAccessSink_somUninit(somSelf);
- }
- FW_SOM_UNINIT_CATCH
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_OResourceSink__Read
- //----------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK FW_OResourceSink__Read(FW_OResourceSink *somSelf, Environment *ev,
- void* destination,
- long count)
- {
- FW_OResourceSinkData *somThis = FW_OResourceSinkGetData(somSelf);
- FW_CPrivResSinRep& rep = *somThis->fRep;
-
- FW_SOM_TRY
- {
- rep.fMemorySink->Read(ev, destination, count);
- }
- FW_SOM_CATCH
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_OResourceSink__GetWritableBytes
- //----------------------------------------------------------------------------------------
-
- SOM_Scope long SOMLINK FW_OResourceSink__GetWritableBytes(FW_OResourceSink *somSelf, Environment *ev)
- {
- FW_UNUSED(ev);
- FW_OResourceSinkData *somThis = FW_OResourceSinkGetData(somSelf);
-
- // Resource sinks are read-only
- return 0;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_OResourceSink__Write
- //----------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK FW_OResourceSink__Write(FW_OResourceSink *somSelf, Environment *ev,
- void* source,
- long count)
- {
- FW_UNUSED(ev);
- FW_UNUSED(source);
- FW_UNUSED(count);
- FW_OResourceSinkData *somThis = FW_OResourceSinkGetData(somSelf);
-
- FW_ASSERT(("Resource sinks are read-only", FALSE));
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_OResourceSink__GetLength
- //----------------------------------------------------------------------------------------
-
- SOM_Scope long SOMLINK FW_OResourceSink__GetLength(FW_OResourceSink *somSelf, Environment *ev)
- {
- FW_OResourceSinkData *somThis = FW_OResourceSinkGetData(somSelf);
- FW_CPrivResSinRep& rep = *somThis->fRep;
-
- FW_SOM_TRY
- {
- return rep.fMemorySink->GetLength(ev);
- }
- FW_SOM_CATCH
- return 0;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_OResourceSink__SetLength
- //----------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK FW_OResourceSink__SetLength(FW_OResourceSink *somSelf, Environment *ev,
- long length)
- {
- FW_OResourceSinkData *somThis = FW_OResourceSinkGetData(somSelf);
- FW_CPrivResSinRep& rep = *somThis->fRep;
-
- FW_SOM_TRY
- {
- rep.fMemorySink->SetLength(ev, length);
- }
- FW_SOM_CATCH
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_OResourceSink__GetPosition
- //----------------------------------------------------------------------------------------
-
- SOM_Scope long SOMLINK FW_OResourceSink__GetPosition(FW_OResourceSink *somSelf, Environment *ev)
- {
- FW_OResourceSinkData *somThis = FW_OResourceSinkGetData(somSelf);
- FW_CPrivResSinRep& rep = *somThis->fRep;
-
- FW_SOM_TRY
- {
- return rep.fMemorySink->GetPosition(ev);
- }
- FW_SOM_CATCH
- return 0;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_OResourceSink__SetPosition
- //----------------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK FW_OResourceSink__SetPosition(FW_OResourceSink *somSelf, Environment *ev,
- long position)
- {
- FW_OResourceSinkData *somThis = FW_OResourceSinkGetData(somSelf);
- FW_CPrivResSinRep& rep = *somThis->fRep;
-
- FW_SOM_TRY
- {
- rep.fMemorySink->SetPosition(ev, position);
- }
- FW_SOM_CATCH
- }
-